package com.firesrc.service.impl;

import java.util.List;
import java.util.UUID;

import com.firesrc.bean.ExceptionLog;
import com.firesrc.dao.ExceptionLogDao;
import com.firesrc.dao.impl.ExceptionLogDaoImpl;
import com.firesrc.service.ExceptionLogService;

public class ExceptionLogServiceImpl implements ExceptionLogService {
	private ExceptionLogDao dao;

	public ExceptionLogServiceImpl() {
		dao = new ExceptionLogDaoImpl();
	}

	@Override
	public void add(ExceptionLog exceptionLog) {
		dao.add(exceptionLog);
	}

	@Override
	public void add(Exception e) {
		ExceptionLog exceptionLog = new ExceptionLog();
		exceptionLog.setId(UUID.randomUUID().toString());
		exceptionLog.setCauseMessage(e.getCause().getMessage());
		exceptionLog.setMessage(e.getMessage());
		exceptionLog.setState("0");
		add(exceptionLog);

	}

	@Override
	public List<ExceptionLog> getAll() {
		return dao.getAllList(new ExceptionLog());
	}

}
